package pl.edu.agh.iosr.gamblingzone.model;

import java.util.LinkedList;
import java.util.List;

import javax.persistence.AttributeOverride;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;

@AttributeOverride(name="id",
		column=@Column(name="DISCIPLINE_ID"))
@Entity(name="DISCIPLINE")
public class Discipline extends IEntity {
	
	@Column(name="DISCIPLINE_NAME", nullable=false)
	private String name;
	
	@Column(name="DISCIPLINE_DESCRIPTION", nullable=false)
	private String description;
	
	@OneToMany(mappedBy="discipline", cascade=CascadeType.ALL)
	private List<Group> groups = new LinkedList<Group>();

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public List<Group> getGroups() {
		return groups;
	}
	
	public void addGroup(Group g) {
		g.setDiscipline(this);
		this.groups.add(g);
	}
}
